<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class TestController extends Controller {

    public function uploadImages(Request $request) {
        $file1 = $request->file('photo'); //获取图片 
        $a=0;
        foreach ($file1 as $file){
            $a++;
            $file->move('uploads/goods', $a.".".$file->getClientOriginalExtension());
            $path="/uploads/goods/".$a.".".$file->getClientOriginalExtension(); 
        }
        
//            ($request->hasFile('images')){
//    foreach($request->file('images') as $file) {
//        $file->move(base_path().'/public/uploads/', $file->getClientOriginalName());
//    }
//}
//        $allowed_extensions = ["png", "jpg", "gif"];
//        $filedir = "uploads/goods"; //2、定义图片上传路径 
//        $fileName = $file->getClientOriginalName(); //3、获取上传图片的文件名  
//        $extension = $file->getClientOriginalExtension(); //4、获取上传图片的后缀名 
//        $newImagesName = md5(time()) . random_int(5, 5) . "." . $extension; //5、重新命名上传文件名字
//        $file->move($filedir, $newImagesName); //6、使用move方法移动文件.
    }

}
